package me.a_littlesquid.origin.events;

import me.a_littlesquid.origin.Origin;
import me.a_littlesquid.origin.tasks.wait;
import me.a_littlesquid.origin.utils.check;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerRespawnEvent;

import java.io.File;




public class catchrespawn implements Listener {
    private Origin plugin;
    @EventHandler
    public void onRspawn(PlayerRespawnEvent event){
        Player player=event.getPlayer();
        File filedata=new File(me.a_littlesquid.origin.Origin.getProvidingPlugin(me.a_littlesquid.origin.Origin.class).getDataFolder(),"data.yml");
        FileConfiguration data= YamlConfiguration.loadConfiguration(filedata);
        if(check.hasorigin(player,data,filedata)){
            plugin = Origin.getInstance();
            wait wait=new wait(player);
            wait.runTaskAsynchronously(plugin);
        }
    }
}
